package service;

import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.List;


import Dao.TestDao;
import Dao.TestDaoimpl;
import Dao.WordDaoimpl;
import entity.Test;
import entity.Word;
import util.Dbconnect;

public class TestServiceimpl implements TestService {
    TestDao td = new TestDaoimpl();
    /**
       * Title: randomCommon
       * Description:获取随机数
       * @author 毛立新
       * @param ls
       * @param email
       * @return
       * @throws Exception
     */
	@Override
	public List<Integer> randomCommon(List<Integer> ls, String email) throws Exception {
		// TODO Auto-generated method stub
		return td.randomCommon(ls, email);
	}
    /**
     * Title: getlist
       * Description:获取已背单词wordID列表
       * @author 毛立新
       * @param email
       * @return
       * @throws Exception
     */
	@Override
	public List<Integer> getlist(String email) throws Exception {
		// TODO Auto-generated method stub
		return td.getlist(email);
	}
    /**
     * Title: showByWord
       * Description:按ID获取单词
       * @author 毛立新
       * @param id
       * @return
       * @throws Exception
     */
	@Override
	public String showByWord(int id) throws Exception {
		// TODO Auto-generated method stub
		return td.showByWord(id);
	}
	
	/**
	 * 
		* Title: Showword
		* Description:按随机数获取单词
		* @author 毛立新
	    *
	 */
	 public List<Word> Showword(String email) throws Exception {
		List<Integer> li = new TestDaoimpl().randomCommon(new TestDaoimpl().getlist(email),email);
		List<Word> lw = new ArrayList<Word>();
		for(int i = li.size();i>1;i--) {
			lw.add(new WordDaoimpl().getbyid(li.get(i-1)));
		}
		return lw;
	 }

    /**
     * Title: Getscore
       * Description:获得前端分数
       * @author 毛立新
       * @param email
       * @return
       * @throws Exception
     */
	@Override
	public Integer Getscore(String email) throws Exception {
		// TODO Auto-generated method stub
		return td.Getscore(email);
	}
	/**
	 * Title: updatescore
	 * Description:分数的上传
	 * @author 毛立新
	 * @param email
	 * @param score
	 * @return
	 * @throws Exception
	 */
	public void updatescore (String email,int score) throws Exception{
		td.updatescore(email, score);
	}

    /**
     * Title: deletescore
       * Description:删除score
       * @author 毛立新
       * @param email
       * @throws Exception
     */
    @Override
    public void deletescore(String email) throws Exception {
	    // TODO Auto-generated method stub
    	td.deletescore(email);
    }
    /**
     * Title: addtest
       * Description:添加记录
       * @author 毛立新
       * @param email
       * @param score
       * @return
       * @throws Exception
     */
    @Override
    public int addtest(String email, int score) throws Exception {
	    // TODO Auto-generated method stub
	    return td.addtest(email, score);
    }
    /**
     * Title: isaddorupdate
     * Description:判断是修改信息还是上传信息
     * @author 毛立新
     * @throws Exception
     */
    public boolean isaddorupdate(String email,int score)throws Exception {
    	
    	return td.isaddorupdate(email, score);
    	
    }
    public static void main(String[] args) throws Exception {
	String email = "226313034@qq.com";
	int score = 89;
	new TestServiceimpl().isaddorupdate(email,score);
}
	
    
    
}
